﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;
using System.IO;

/// <summary>
///CommonUtils 的摘要说明
/// </summary>
public class CommonUtils
{
    public CommonUtils()
    {
        //
        //TODO: 在此处添加构造函数逻辑
        //
    }

    public static string GetRoleValue(string str_Value)
    {
        string returnValue = "";
        switch (str_Value)
        {
            case "1":
                returnValue = "自强会员";
                break;
            case "2":
                returnValue = "天使会员";
                break;
            case "3":
                returnValue = "后台管理员";
                break;
            case "4":
                returnValue = "公益团体";
                break;
            default:
                returnValue = "你是谁";
                break;
        }
        return returnValue;
    }
    public static string GetGenderValue(string str_Value)
    {
        string returnValue = "";
        switch (str_Value)
        {
            case "1":
                returnValue = "男";
                break;
            case "2":
                returnValue = "女";
                break;
            default:
                returnValue = "未知";
                break;
        }
        return returnValue;
    }

    public static string GetInComeValue(string str_Value)
    {
        string returnValue = "";
        switch (str_Value)
        {
            case "1":
                returnValue = "1000以下";
                break;
            case "2":
                returnValue = "1000-3000";
                break;
            case "3":
                returnValue = "3000-5000";
                break;
            case "4":
                returnValue = "5000-8000";
                break;
            case "5":
                returnValue = "8000-10000";
                break;
            case "6":
                returnValue = "10000-20000";
                break;
            case "7":
                returnValue = "20000-50000";
                break;
            case "8":
                returnValue = "50000以上";
                break;
            default:
                returnValue = "未知";
                break;
        }
        return returnValue;
    }

    public static string GetEducationValue(string str_Value)
    {
        string returnValue = "";
        switch (str_Value)
        {
            case "1":
                returnValue = "小学或以下";
                break;
            case "2":
                returnValue = "初中";
                break;
            case "3":
                returnValue = "高中/职业高中";
                break;
            case "4":
                returnValue = "中专/技校";
                break;
            case "5":
                returnValue = "大专/大学非本科";
                break;
            case "6":
                returnValue = "大学本科/学士";
                break;
            case "7":
                returnValue = "研究生/硕士";
                break;
            case "8":
                returnValue = "博士及以上";
                break;
            default:
                returnValue = "未知";
                break;
        }
        return returnValue;
    }

    public static string GetProvinceValue(string str_Value)
    {
        string returnValue = "";
        try
        {
            string CurrentPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Code");
            if (System.IO.File.Exists(CurrentPath + "//Province.xml"))
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.Load(CurrentPath + "//Province.xml");
                XmlNode nodProvince = doc.DocumentElement.SelectSingleNode(@"Province[@Code='" + str_Value + "']");

                if (nodProvince != null)
                {
                    returnValue = nodProvince.Attributes["Name"].Value;
                }
            }
        }
        catch (Exception ex)
        {
        }
        return returnValue;
    }

    public static string GetCityValue(string str_Value)
    {
        string returnValue = "";
        try
        {
            string CurrentPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Code");
            if (System.IO.File.Exists(CurrentPath + "//Province.xml"))
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.Load(CurrentPath + "//Province.xml");

                XmlNode nodCity = doc.DocumentElement.SelectSingleNode(@"Province/City[@Code='" + str_Value + "']");

                if (nodCity != null)
                {
                    returnValue = nodCity.Attributes["Name"].Value;
                }
            }
        }
        catch (Exception ex)
        {
        }
        return returnValue;
    }
}